
name = input("Please enter your name:")
print("Hello ," + name + "!")
prompt = "If you tell us who you are,we can personalize the messages you see."
prompt += "\nWhat is your first name?"
name = input(prompt)
print("\nHello," + name + "!")
age = input("How old are you?")
age = int(age)
if age >= 18:
	print(True)

def greet_user(username):
	"""显示简单的问候语"""
	print("Hello," + username.title() + "!")
greet_user('k')
def display():
	"""显示"""
	print("函数")
display()
def describe_pet(animal_type,pet_name):
	"""显示宠物的信息"""
	print("\nI have a " + animal_type + ".")
	print("My " + animal_type + "'s name is " + pet_name.title() + ".")
describe_pet('hamaster','harry')
describe_pet('dog','willie')
def describe_pet(pet_name,animal_type = 'dog'):
	"""显示宠物的信息"""
	print("\nI have a " + animal_type + ".")
	print("My " + animal_type + "'s name is " + pet_name.title() + ".")
describe_pet(pet_name = 'willie')
def get_formatted_name(first_name,last_name):
	"""返回整洁的姓名"""
	full_name = first_name + " " + last_name
	return full_name.title()
# 这是一个无限循环(添加break前)
while True:
	print("\nPlease tell me your name:")
	f_name = input("First name")
	l_name = input("Last name")
	formatted_name = get_formatted_name(f_name,l_name)
	print("\nHello, " + formatted_name + "!")
	break
# 修改后	
def get_formatted_name(first_name,last_name):
	"""返回整洁的姓名"""
	full_name = first_name + " " + last_name
	return full_name.title()
while True:
	print("\nPlease tell me your name:")
	print("(enter 'q' at any time to quit)")
	f_name = input("First name")
	if f_name == 'q':
		break
	l_name = input("Last name")
	if l_name == 'q':
		break
	formatted_name = get_formatted_name(f_name,l_name)
	print("\nHello, " + formatted_name + "!")
